﻿using UnityEngine;

namespace Core.Trail
{
    public class TrailEffect : Component, IAwake<GameObject>, IUpdate
    {
        private TrailRenderer renderer;
        private GameObject gameObject;

        public float Speed { get; private set; }

        public float Duration { get; private set; }

        public void Awake(GameObject go)
        {
            gameObject = go;
            renderer = go.GetComponent<TrailRenderer>();
            renderer.time = 1;
        }

        public override void Dispose()
        {
            if (IsDisposed) return;
            base.Dispose();

            Utils.Trans.Destroy(gameObject);
            gameObject = null;
            renderer = null;
        }

        public void Update()
        {
        }

        public void MoveImmediate(Vector3 pos)
        {
            Utils.Trans.SetActive(gameObject, false);
            gameObject.transform.position = pos;
            Utils.Trans.SetActive(gameObject, true);
        }

        public void MoveTo(Vector3 pos, float speed)
        {

        }

    }
}
